//
//  HPFastTransferViewController.m
//  HPZZTong
//
//  Created by handpay on 14-4-4.
//  Copyright (c) 2014年 Handpay. All rights reserved.
//

#import "HPFastTransferViewController.h"
#import "ZZTongUtility.h"
#import "HPTransferConfirmView.h"
#import "HPFastTransferViewController.h"
#import "ZZTFastTransfer.h"
//#import "POSUIEngine.h"
#import "RFPOSUIEngine.h"
#import "RFCSNValidatorController.h"
#import <HandPaySwiperModule/HandPaySwiperModule.h>
#import <HandPaySwiperModule/SwipeInfo.h>


#define KCardInfo      100001
#define KAmount        100002

#define CONNENT_LABEL             @"label"

#define KTerminalId                 @"terminalId"
#define KEncryCurrency              @"encryCurrency"
#define KAccountNumber2             @"accountNumber2"
#define KEncryAmt                   @"encryAmt"

@interface HPFastTransferViewController (){
    int encryDataCount;
}

@property(nonatomic, retain) NSDictionary* paramsDic;
@property(nonatomic, retain) NSString* totalMoney;
@property(nonatomic, retain) HPTransferConfirmView *confirmView;
@property(nonatomic, retain) NSString* terminalId;
@property(nonatomic, retain) NSString* encryCurrency;
@property(nonatomic, retain) NSString* encryAmt;
@property(nonatomic, retain) NSString* accountNumber2;
@property(nonatomic, retain) NSString* fee;
@property(nonatomic, retain) NSString* macResult;
@property(nonatomic, retain) NSString* bankCard;

@property(nonatomic, retain) ZZTFastTransfer * fastProcess;
@property(nonatomic, retain) RFPOSUIEngine* processMointer; // mcm new

@end

@implementation HPFastTransferViewController

@synthesize totalMoney;
@synthesize fee;
@synthesize confirmView;
@synthesize encryCurrency;
@synthesize accountNumber2;
@synthesize terminalId;
@synthesize macResult;
@synthesize paramsDic;
@synthesize encryAmt;
@synthesize bankCard;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    }
    return self;
}

- (void)viewDidLoad
{
    self.title = @"快速转账";
    [super viewDidLoad];
    
    self.agreeButton.selected = YES;
    
    self.cardInfoTableView.tag = KCardInfo;
    self.cardInfoTableView.dataSource = self;
   
    self.amountTableView.tag = KAmount;
    self.amountTableView.dataSource = self;
    
    [self.transferButton setBackgroundImage:[[UIImage imageNamed:@"bluebutton.png"] stretchableImageWithLeftCapWidth:9 topCapHeight:0] forState:UIControlStateNormal];
    
    [self.transferButton setBackgroundImage:[[UIImage imageNamed:@"bluebuttonhover.png"] stretchableImageWithLeftCapWidth:9 topCapHeight:0] forState:UIControlStateHighlighted];
    
    UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
    [b setFrame:CGRectMake(0, 0, 44, 44)];
    [b setContentEdgeInsets:UIEdgeInsetsMake(10, 20, 10, 0)];
    [b setImage:[UIImage imageNamed:@"more.png"] forState:UIControlStateNormal];
    [b addTarget:self action:@selector(showCardPack) forControlEvents:UIControlEventTouchUpInside];
    
    [super setRightButton:b];
}
- (void)showCardPack{
    [self.accountTextField resignFirstResponder];
    [self.nameTextField resignFirstResponder];
    [self.amountTextField resignFirstResponder];
    [HPUIENG showScreen:SCR_CARD_OR_RECORD params:@{@"appCode": @"3"}];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (void)dealloc {
    [_cardInfoTableView release];
    [_amountTableView release];
    [_agreeButton release];
    [_transferButton release];
    [_accountTextField release];
    [_amountTextField release];
    [_nameTextField release];
    
    self.processMointer = nil; // mcm new
    self.paramsDic = nil;
    self.confirmView = nil;
    self.terminalId = nil;
    self.totalMoney = nil;
    self.accountNumber2 = nil;
    self.encryCurrency = nil;
    self.paramsDic = nil;
    self.fee = nil;
    self.macResult = nil;
    self.encryAmt = nil;
    self.bankCard = nil;
    [super dealloc];
}
- (void)viewDidUnload {
    [self setCardInfoTableView:nil];
    [self setAmountTableView:nil];
    [self setAgreeButton:nil];
    [self setTransferButton:nil];
    [self setAccountTextField:nil];
    [self setAmountTextField:nil];
    [self setNameTextField:nil];
    [super viewDidUnload];
}

- (IBAction)desClick:(id)sender {
    [self.accountTextField resignFirstResponder];
    [self.nameTextField resignFirstResponder];
    [self.amountTextField resignFirstResponder];
    NSDictionary* params = @{@"title": @"快速转账说明",
                             @"url": @"kuaisuzz",
                             @"type"    : transTypeFastTransfer};
    [HPUIENG showScreen:SCR_HELP params:params];
}

- (IBAction)agreeClick:(id)sender {
    self.agreeButton.selected = !self.agreeButton.selected;
}

- (IBAction)transferClick:(id)sender {
    if (!self.agreeButton.selected) {
        [HPUIENG showAlert:@"请先同意转账说明"];
        return;
    }
    if (![ZZTongUtility checkIsInput:self.accountTextField tips:@"银行卡号"]) {
        [self.accountTextField becomeFirstResponder];
        return;
    }
    NSString* tempAccount = [self.accountTextField.text stringByReplacingOccurrencesOfString:@" " withString:@""];
    if (![Utility isLegalCard:tempAccount length:0]) {
        [HPUIENG showAlert:@"请输入正确的银行卡号"];
        [self.accountTextField becomeFirstResponder];
        return;
    }
    
    if (![ZZTongUtility checkName:self.nameTextField.text tips:@"持卡人姓名"]) {
        [self.nameTextField becomeFirstResponder];
        return;
    }
    
    NSString* moneyStr = self.amountTextField.text;
    if ([NSString isNilOrEmpty:moneyStr]){
        [HPUIENG showAlert:@"请输入转账金额"];
        [self.amountTextField becomeFirstResponder];
        return;
    }
    
    long money = (long)([moneyStr doubleValue] * 100);
    if (money <= 0) {
        [HPUIENG showAlert:@"请输入转账金额"];
        [self.amountTextField becomeFirstResponder];
        return;
    }
    [self.accountTextField resignFirstResponder];
    [self.nameTextField resignFirstResponder];
    [self.amountTextField resignFirstResponder];
    
    [self beginFastProcess];
}

// mcm
//- (void)beginFastProcess
//{
//    _fastProcess = [[ZZTFastTransfer alloc] init];
//    NSString * moneyStr = [self.amountTextField.text stringByReplacingOccurrencesOfString:@"." withString:@""];
//    _fastProcess.plainAmount = [Utility leftPadding:moneyStr withTotalCount:12 withChar:@"0"];
//    NSString * account2 = [self.accountTextField.text stringByReplacingOccurrencesOfString:@" " withString:@""];
//    _fastProcess.plainAccount2 = account2;
//    [_fastProcess beginWithDelegate:self];
//}

// mcm new
-(void)beginFastProcess
{
    self.fastProcess = (ZZTFastTransfer*)[[HPSwiperContext sharedInstance] processorWithBindingInfo:nil
                                                                                       businessType:HPPOSBusinessTypeFastTransfer];
    self.processMointer = [[RFPOSUIEngine alloc] initWithPOSProcess:self.fastProcess];
    
    NSString * moneyStr = [self.amountTextField.text stringByReplacingOccurrencesOfString:@"." withString:@""];
    self.fastProcess.plainAmount = [Utility leftPadding:moneyStr withTotalCount:12 withChar:@"0"];
    
    NSString * account2 = [self.accountTextField.text stringByReplacingOccurrencesOfString:@" " withString:@""];
    self.fastProcess.plainAccount2 = account2;
    
    [self.fastProcess beginWithDelegate:self];
}

- (BOOL)process:(id)process didGetSwipeInfo:(SwipeInfo *)swipeInfo
{
    self.transferButton.userInteractionEnabled = NO;
    self.bankCard = swipeInfo.plainAccount;
    [HPUIENG popScreen];
    [self queryFee];
    return NO;
}

- (void)selectApplication:(id)process result:(HPSwiperResult *)result{
    NSArray* array = (NSArray*)result.value;
    
    NSMutableArray* mutArray = [NSMutableArray array];
    
    for (int i = 0; i<array.count; i++) {
        NSString* strData = [array objectAtIndex:i];
        if (![NSString isNilOrEmpty:strData]) {
            NSString* strTemp = [strData uppercaseString];
            NSString* strName = nil;
            
            NSRange range = [strTemp rangeOfString:@"DEBIT"];
            if (range.length != 0) {
                strName = @"借记卡";
            }
            if (![NSString isNilOrEmpty:strName]) {
                [mutArray addObject:@[strName,strData,[NSNumber numberWithInt:i]]];
            }
        }
    }
    
//    [POSUIENG processSelectApp:mutArray]; // mcm
    [self.processMointer processSelectApp:mutArray]; // mcm new
}
- (BOOL)inputPwdFinished:(id)process
{
    [self checkFourElements];
    return NO;
}

- (void)process:(id)process finishedWithResult:(HPSwiperResult *)result
{
    if (!result.isSuccess)
    {
//        [POSUIEngine processFailed:process result:result]; // mcm
        [RFPOSUIEngine processFailed:process result:result]; // mcm new
    }
    else
        [self doFastTransfer];
    self.transferButton.userInteractionEnabled = YES;
}

- (void)doFastTransfer{
    
    ZZTongClientEngine* zztEngine = [ZZTongClientEngine sharedInstance];
    [zztEngine.uiEngine showNetWaiting];
//    [HPUIENG getAddressWithGPSBlock:^(NSString *latitude, NSString *longitude, NSString *address, NSError *error) {
        NSMutableDictionary* params = [NSMutableDictionary dictionaryWithCapacity:10];
        
        [params setObject:self.fastProcess.encTerminalID forKey:@"terminalId"];
        [params setObject:self.fastProcess.time forKey:@"transTime"];
        [params setObject:[zztEngine getChannel] forKey:@"channel"];
        [params setObject:DES_ENC(self.totalMoney) forKey:@"channelOrderAmt"];
        [params setObject:self.fastProcess.encAmount forKey:@"encryAmt"];
        [params setObject:self.fastProcess.plainCurrency forKey:@"channelOrderCurrency"];
        [params setObject:self.fastProcess.encCurrency forKey:@"encryCurrency"];
        [params setObject:DES_ENC(self.fastProcess.swipeInfo.plainAccount) forKey:@"cardNum"];
    
        if (![NSString isNilOrEmpty:self.fastProcess.encAccount]) {
            [params setObject:self.fastProcess.encAccount forKey:@"accountNumber1"];
        }else if(![NSString isNilOrEmpty:self.fastProcess.swipeInfo.encAccount]){
            [params setObject:self.fastProcess.swipeInfo.encAccount forKey:@"accountNumber1"];
        }
        if (![NSString isNilOrEmpty:self.fastProcess.encPin]) {
            [params setObject:self.fastProcess.encPin forKey:@"pan"];
        }else if(![NSString isNilOrEmpty:self.fastProcess.swipeInfo.encPin]){
            [params setObject:self.fastProcess.swipeInfo.encPin forKey:@"pan"];
        }
        [params setObject:DES_ENC(self.fastProcess.plainAccount2) forKey:@"acccountNum"];
        [params setObject:self.fastProcess.encAccount2 forKey:@"accountNumber2"];
        [params setObject:DES_ENC(self.fastProcess.csn) forKey:@"cardSerialNumber"];
        
        [params setObject:DES_ENC(self.fee) forKey:@"fee"];

//        [params setObject:[CSNValidator getLocation] forKey:KEY_LOCATION]; // mcm
//        [params setObject:[CSNValidator getAddress] forKey:KEY_ADDRESS]; // mcm
        RFCSNValidatorController* validator = [RFCSNValidatorController sharedInstance]; // mcm new
        [params setObject:validator.location forKey:KEY_LOCATION]; // mcm new
        [params setObject:validator.address forKey:KEY_ADDRESS]; // mcm new
    
        [params setObject:DES_ENC(ZZT_CLIENG.accountInfo.account) forKey:@"account"];
        [params setObject:_fastProcess.encMac forKey:@"mac"];
        [params setObject:DES_ENC(self.nameTextField.text) forKey:@"accountName"];
        if (_fastProcess.icMode)
        {
            if (_fastProcess.swipeInfo.icNumber.length > 0)
            {
                [params setObject:_fastProcess.swipeInfo.icNumber forKey:@"ICNumber"];
            }
            [params setObject:_fastProcess.swipeInfo.dcData forKey:@"DCData"];
        }
        if (![NSString isNilOrEmpty:_fastProcess.swipeInfo.encTrack2]) {
            [params setObject:_fastProcess.swipeInfo.encTrack2 forKey:@"track2Data"];
        }
        if (![NSString isNilOrEmpty:_fastProcess.swipeInfo.dynamicKey]) {
            [params setObject:_fastProcess.swipeInfo.dynamicKey forKey:@"dynamicKeyData"];
        }
        [zztEngine.netEngine sendRequest:NET_ACTION_SUBATM_TRANSFER withParams:params withDelegate:self];
//    }];
}

- (void)queryFee{
    ZZTongClientEngine* zztEngine = [ZZTongClientEngine sharedInstance];
    [zztEngine.uiEngine showNetWaiting];
    
    long money = (long)([self.amountTextField.text doubleValue] * 100);
    NSString* amount = [NSString stringWithFormat:@"%ld",money];
    amount = DES_ENC(amount);
    
    NSString* inCardNo = [self.accountTextField.text stringByReplacingOccurrencesOfString:@" " withString:@""];
    // mcm
//    NSDictionary* params = @{KEY_AMOUNT: amount,
//                             KEY_CSN: DES_ENC(SWIPERENG.csn),
//                             KEY_CHANNEL: [zztEngine getChannel],
//                             @"accountType": @"K",
//                             @"inCardNo": DES_ENC(inCardNo),
//                             @"outCardNo": DES_ENC(self.bankCard),
//                             KEY_ACCOUNT : DES_ENC(ZZT_CLIENG.accountInfo.account)
//                             };
    NSDictionary* params = @{KEY_AMOUNT: amount,
                             KEY_CSN: DES_ENC([HPSwiperContext sharedInstance].connectedDeviceCSN),
                             KEY_CHANNEL: [zztEngine getChannel],
                             @"accountType": @"K",
                             @"inCardNo": DES_ENC(inCardNo),
                             @"outCardNo": DES_ENC(self.bankCard),
                             KEY_ACCOUNT : DES_ENC(ZZT_CLIENG.accountInfo.account)
                             };

    
    [zztEngine.netEngine sendRequest:NET_ACTION_SUBATM_QUERY_FEE withParams:params withDelegate:self];
}

- (void)checkFourElements
{
    ZZTongClientEngine* zztEngine = [ZZTongClientEngine sharedInstance];
    [zztEngine.uiEngine showNetWaiting];
    
    
    NSDictionary* params = @{
                             KEY_CHANNEL: [zztEngine getChannel],
                             KEY_CSN: [HPSwiperContext sharedInstance].connectedDeviceCSN,
                             @"cardNum": DES_ENC(self.bankCard),
                             };
    
    [zztEngine.netEngine sendRequest:NET_ACTION_QUERY_FOUR_ELEMENTS withParams:params withDelegate:self];
}

- (void)treatTransferSuccess:(NSDictionary*)respData{
    
    NSString* transTime = [Utility getFormatDate:[respData objectForKey:@"transTime"]];
    NSString* transSN = [respData objectForKey:@"transSN"];
    NSString* transStatus = [respData objectForKey:@"transStatus"];
    NSString* status = [respData objectForKey:@"status"];
    if (!transStatus)
    {
        transStatus = @"";
    }
//    NSString* status = ([[respData objectForKey:@"status"] isEqualToString:@"1"] ? @"交易成功" : @"交易失败");
    NSString* cardNoOut = [Utility encryptCardID:[respData objectForKey:@"cardNoOut"]];
    NSString* amount = [Utility getFormatMoneyAndSymbol:[respData objectForKey:KEY_AMOUNT]];
    NSString* cardNoIn = [Utility encryptCardID:[respData objectForKey:@"cardNoIn"]];
    NSString* fee_ = [Utility getFormatMoneyAndSymbol:[respData objectForKey:KEY_FEE]];
    NSString* total = [Utility getFormatMoneyAndSymbol:[respData objectForKey:KEY_TOTAL]];
   

    if ([status isEqualToString:@"1"]) {
        NSArray*  aboveData = @[@[@"交易金额", total],
                                @[@"转出卡号", cardNoOut],
                                @[@"交易状态", @"交易成功"],
                                @[@"交易时间", transTime],
                                @[@"交易流水号", transSN]];
        
        NSArray* belowData = @[@[@"交易类型",   @"快速转账"],
                               @[@"收款人账号", cardNoIn],
                               @[@"收款人姓名", self.nameTextField.text],
                               @[@"转账金额", amount],
                               @[@"手续费", fee_]];
        NSDictionary* dic = @{kBelowData: belowData,
                              kAboveData: aboveData,
                              kBusinissType:transResult};
        [HPUIENG showScreen:SCR_TRANSACTION_SUCCESS params:dic];
    }else{
        NSString* detailStatus = @"";
        NSString* statusTips = @"";
        if ([status isEqualToString:@"2"]) {
            detailStatus = @"交易处理中";
        }else if([status isEqualToString:@"0"]){
            detailStatus = @"交易失败";
            statusTips = @"失败原因";
        }
        NSArray*  aboveData = @[@[@"交易金额", total],
                                @[@"转出卡号", cardNoOut],
                                @[@"交易状态", detailStatus],
                                @[@"交易时间", transTime],
                                @[@"交易流水号", transSN],
                                @[@"交易类型",   @"快速转账"],
                                @[@"收款人账号", cardNoIn],
                                @[@"收款人姓名", self.nameTextField.text]];
        
        NSArray* belowData = @[@[statusTips, transStatus, @"3"]];
        NSDictionary* dic = @{kTransType: transTypeFastTransfer,
                              kBusinissType:transResult,
                              kAboveData: aboveData,
                              kBelowData: belowData,
                              @"status": status};
        [HPUIENG showScreen:SCR_TRANSACTION_FAIL params:dic];
    }
}

- (void)treatQueryFeeSuccess:(NSDictionary*)respData{
    
    NSString* tId = [respData objectForKey:KTerminalId];
    LOG(@"terminalId::%@",tId);
    self.terminalId = DES_DEC(tId);
    LOG(@"terminalId DES_DEC::%@", self.terminalId);
    
    NSDictionary* cardDic = @{kValue: self.accountTextField.text, CONNENT_LABEL : @"转入卡号"};
    NSDictionary* fromCardDic = @{kValue: self.nameTextField.text, CONNENT_LABEL: @"收款人姓名"};
    NSDictionary* transferAmountDic = @{kValue: @"1小时以内", CONNENT_LABEL: @"到账时间"};
    
    NSString* moneyStr = self.amountTextField.text;
    
    //现在金额只是保留小数点后2位(最后的单位为分）
    moneyStr = [moneyStr stringByReplacingOccurrencesOfString:@"." withString:@""];
    long money = moneyStr.intValue;
    
    moneyStr = [NSString stringWithFormat:@"%ld",money];
    
    NSDictionary* transferFeeDic = @{kValue: [Utility getFormatMoneyAndSymbol:moneyStr], CONNENT_LABEL: @"转账金额"};
    
    self.fee = [respData objectForKey:KEY_FEE];
    NSDictionary* transferPoundage = @{kValue: [Utility getFormatMoneyAndSymbol:self.fee], CONNENT_LABEL: @"转账手续费"};
    
    long total = money + fee.intValue;
    
    self.totalMoney = [NSString stringWithFormat:@"%ld",total];
    
    NSDictionary* totalAmountDic = @{kValue:[Utility getFormatMoneyAndSymbol:self.totalMoney], CONNENT_LABEL: @"实付总额", @"features": [NSNumber numberWithInt:1]};
    
    
    NSArray* aboveData = @[cardDic, fromCardDic, transferAmountDic, transferFeeDic, transferPoundage];
    NSArray* belowData = @[totalAmountDic];
    
    NSDictionary* confirmData = @{@"aboveData": aboveData,
                                  @"belowData": belowData};
    [self performSelectorOnMainThread:@selector(showConfrimView:) withObject:confirmData waitUntilDone:YES];
}

- (void)treatFourElementsSuccess:(NSDictionary *)respData
{
    NSString * status = [respData objectForKey:@"status"];
    if ([status intValue] == 0)
    {
        [HPUIENG removeWaiting];
        NSDictionary * screenDic = @{@"cardNo": self.bankCard,
                                      @"amount": [Utility getFormatMoneyAndSymbol:self.totalMoney]};
        self.transferButton.userInteractionEnabled = YES;
        [HPUIENG showScreen:SCR_CARD_IDENTIFY params:screenDic];
    }
    else
    {
        [_fastProcess continueAction];
    }
}

- (void)cardIdentifySuccessed
{
    [_fastProcess continueAction];
}

- (void)affirmAmount
{
    _fastProcess.plainAmount = [Utility leftPadding:self.totalMoney withTotalCount:12 withChar:@"0"];
    _fastProcess.plainTerminalID = self.terminalId;
    [_fastProcess continueAction];
}

- (void)confirmViewCancelback{
    self.transferButton.userInteractionEnabled = YES;
}

- (void)confirmViewCallback
{
    [HPUIENG removeWaiting];
    [self affirmAmount];
}
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [ZZT_UIENG hideNavigationBar:NO];
    self.transferButton.userInteractionEnabled = YES;
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [ZZT_UIENG hideNavigationBar:NO];
}
- (void)showConfrimView:(NSDictionary*)confirmData{
    
    if (self.confirmView) {
        self.confirmView = nil;
    }
    UIWindow* keyWindow = [UIApplication sharedApplication].keyWindow;
    HPTransferConfirmView* tempView = [[HPTransferConfirmView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.confirmView = tempView;
    [keyWindow addSubview:self.confirmView];
    
    [tempView release];
    
    CallbackData* callbackData = [[CallbackData alloc] initWithTarget:self callback:@selector(confirmViewCallback)];
    [self.confirmView setContentData:confirmData callback:callbackData];
    
    CallbackData* cancelData = [[CallbackData alloc] initWithTarget:self callback:@selector(confirmViewCancelback)];
    [self.confirmView setCancelCallback:cancelData];
    
    [keyWindow bringSubviewToFront:self.confirmView];
    [callbackData release];
    [cancelData release];
}

- (void)responseCallBackSuccess:(NSString *)action withData:(NSDictionary *)respData
{
    if ([action isEqualToString:NET_ACTION_SUBATM_QUERY_FEE]){
        [self treatQueryFeeSuccess:respData];
    }else if ([action isEqualToString:NET_ACTION_SUBATM_TRANSFER]){
        [HPUIENG removeWaiting];
        [self treatTransferSuccess:respData];
    }
    else if([action isEqualToString:NET_ACTION_QUERY_FOUR_ELEMENTS])
    {
        [self treatFourElementsSuccess:respData];
    }
}

- (void)responseCallBackFailed:(NSString *)action withErrCode:(NSString *)errCode withErrMsg:(NSString *)msg{
    if ([action isEqualToString:NET_ACTION_SUBATM_QUERY_FEE])
    {
        self.transferButton.userInteractionEnabled = YES;
    }
    if ([action isEqualToString:NET_ACTION_SUBATM_TRANSFER] || [action isEqualToString:NET_ACTION_QUERY_FOUR_ELEMENTS]) {

        if ([HPUIENG getCurrentScreen] != self)
        {
            [HPUIENG popScreen];
        }
    }
    
}
#pragma UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (tableView.tag == KCardInfo) {
        return 2;
    }
    return 1;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell* cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    
    UILabel* desLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 100, 44)];
    desLabel.textColor = kNormalFontColor;
    desLabel.font = kNormalFont;
    
    HPConditionTextField* textField = [[HPConditionTextField alloc] initWithFrame:CGRectMake(110, 0, 200, 44)];
    textField.textColor = kNormalFontColor;
    textField.font = kNormalFont;
    textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    
    if (tableView.tag == KAmount) {
        desLabel.text = @"转账金额";
        textField.conditionType = HPConditionType_Money;
        [textField setMaxLength:9];
        self.amountTextField = textField;
        textField.placeholder = @"请输入金额";
        
    }else{
        switch (indexPath.row) {
            case 0:
                desLabel.text = @"收款人账号";
                textField.conditionType = HPConditionType_CardNo;
                textField.placeholder = @"请输入收款人账号";
                self.accountTextField = textField;
                break;
            case 1:
                desLabel.text = @"持卡人姓名";
                textField.conditionType = HPConditionType_Deafult;
                textField.placeholder = @"请输入姓名";
                self.nameTextField = textField;
                break;
            default:
                break;
        }
    }
    [cell addSubview:desLabel];
    [desLabel release];
    
    [cell addSubview:textField];
    [textField release];

    return  [cell autorelease];
}


@end




